package com.jiyun.controller;

import com.jiyun.common.result.Result;
import com.jiyun.model.pojo.User;
import com.jiyun.service.UserService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("admin/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/UpdatePrice")
    @ApiOperation("修改价格")
    public Result updatePrice(@RequestBody User user){

        userService.updatePrice(user);
        return Result.ok().code(200);
    }

















    @PutMapping("update")
    @ApiOperation("修改")
    public Result updateById(@RequestBody User user) {
        System.out.println(user);
        userService.updateById(user);
        return Result.ok();
    }

    @GetMapping("/getCoupon/{id}")
    @ApiOperation("查询当前账号的优惠卷")
    public Result getCoupon(@PathVariable("id") Long id) {
        List<User> list = userService.getCoupon(id);
        log.info("list:{}"+list);
        return Result.ok(list);
    }
    @GetMapping("/getCountCoupon/{id}")
    @ApiOperation("查询当前账号的优惠卷个数")
    public Result getCountCoupon(@PathVariable Long id) {
        int list = userService.getCountCoupon(id);
        return Result.ok(list);
    }
    @PostMapping("/updatMoney/{id}/{money}")
    @ApiOperation("充值金额")
    public Result updateMoney(@PathVariable Integer id,@PathVariable Integer money) {
        Integer i = userService.updateMonuey(id, money);
        return Result.ok(i);
    }
}
